//60秒之后获取验证码
var wait=60; 
 registerVue = new Vue({
    el:'#register',
    data:{
        QQmail:'',
        userName:'',
        pwd:'',
        icode:''
    },
    methods:{
        getCode:function(){
            $.ajax({
                url:'getCode',
                type:'POST',
                cache:false,
                dataType:'json',
                data:{
                    emil:this.QQmail
                },
                success:function(data){
                    if(data.info === "验证码发送成功，有效时间为两分钟！"){
                        window.time();
                        alert(data.info);
                    }else{
                        alert(data.info);
                    }

                },
                error:function(){
                    alert("请刷新网络")
                }
            })
            window.time();
        },
        finish:function(){
            $.ajax({
                url:'register',
                type:'POST',
                cache:false,
                dataType:'json',
                data:{
                    QQEmil:this.QQmail,
                    userName: this.userName,
                    password:this.pwd,
                    code:this.icode

                },
                success:function(data){
                    alert(data.info);
                },
                error:function(){
                    alert("请刷新网络")
                }
            })
        }
    }
});

function time(){
    if (wait == 0) { 
        document.getElementById("btn_getcode").removeAttribute("disabled");    
        document.getElementById("btn_getcode").value = "重新发送";
        wait = 60; 
    } else { 
        document.getElementById("btn_getcode").setAttribute("disabled", true); 
        document.getElementById("btn_getcode").value = wait+"秒后重新发送";
        wait--; 
        setTimeout(function() { 
            time() 
        }, 
        1000) ;
    } 
};
